package cn.snowsoft.iot.module.warning.ekuiperClient;

import cn.snowsoft.iot.module.warning.utils.HttpUtil;
import com.alibaba.fastjson.JSONObject;

public class WarningClient {

    public static boolean streamCreation(JSONObject data, String url) {
        String requestUrl = url + "/streams";
        String response = HttpUtil.sendPost(requestUrl, data);
        return response != null && !response.isEmpty();
    }



    public static boolean streamDelete(String id, String url) {
        String requestUrl = url + "/streams/" + id;
        return HttpUtil.sendDelete(requestUrl);
    }



    public static boolean ruleCreation(JSONObject data, String url) {
        String requestUrl = url + "/rules";
        String response = HttpUtil.sendPost(requestUrl, data);
        return response != null && !response.isEmpty();
    }

    public static boolean ruleDelete(String id, String url) {
        String requestUrl = url + "/rules/" + id;
        return HttpUtil.sendDelete(requestUrl);
    }


    public static boolean ruleRestart(String id, String url) {
        String requestUrl = url + "/rules/" + id + "/restart";
        String response = HttpUtil.sendPost(requestUrl, null);
        return response != null && !response.isEmpty();
    }


}
